
<template>
<h2>登录页面</h2>
<table>
    <tr>
        <td>手机号:</td>
        <td>
            <input type="text" v-model="phone" placeholder="请输入手机号">
        </td>
    </tr>
    <tr>
        <td>密码:</td>
        <td>
            <input type="password" v-model="pwd" placeholder="请输入密码">
        </td>
    </tr>
    <tr>
        <td colspan="2" style="text-align: center;">
            <input type="button"  @click="Onclick"  value="注册">
        </td>
    </tr>
</table>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { useRouter } from 'vue-router';

import axios from 'axios';

const router = useRouter();
const phone = ref('');
const pwd = ref('');


const Onclick=()=>{
    axios({
        method:"post",
        url:"http://localhost:56383/api/Good/RegisterAdd",
        data:{
            phone:phone.value,
            pwd:pwd.value
        }
    })
    .then(function(res:any)
    {
        
        if(res.data!=null)
        {
            alert("注册成功");
            router.push('/login');
        }
        else
        {
            alert("注册失败");
            return;
        }
    })
}

</script>